/***************************************************************************************
Firm-embedded productivity and cross-country income differences
Alviarez, Cravino and Ramondo
Journal of Political Economy (2022)

Program: model_02_alttransfercosts.do
Date: October 2022

Description: Constructing the DP dummies (aggregate country effects) under the assumption that technology transfer costs have a destination-specific component

*****************************************************************************************/

*-------------------------------------------------------------------------------
global typeden=1
include "set_directories.do"
set memory 64g
global lf "LF"

*Log
cap log close
log using "${clogs}/model_02_alttransfercosts.log", replace
*-------------------------------------------------------------------------------


*Prepare the data for the regressions
*-----------------------------------------------------------
global conditionforage ""
include "${cmain}/prep_01_forreg.do"

local heading "base_withparent"  
local varinterest sales
local timeframe `" "2016" "' 

if "`heading'"=="base_withparent" {
*-----------------------------------------------------------
local ending "" 
local zz naics  
local var0 "_`varinterest'" 
local name "_base" 
local name1 "_withparent" 
local samp=1  
local title "`zz'`var0'_s`samp'`name'`name1'`ending'"
display "`title'"

global ctryrel FR
local period "`timeframe'"
global nonmarket `" drop if sector1=="" "' 
global cont_firms `" keep if years_after2010>=0 "'
global cont_firms2 `" keep if years_allperiod>=0 "'
local absFEreg "guoFE"
global ind_var dist_sec* lang_sec* 
global guoFEonly=0 
global LHS "ln(sin`var0'`denominator')" 
global numctry `" keep if num_ctry>=0 "' 
global pctiles  `" keep if sin_sales>=0 "'  
global other_restr  `"  "' 
global other_restr2  ""
}
*
display "`title'"
local affparent "1" /*"0" is the default, "1" if keeping even one affiliate after parents are dropped*/ 
include "${cmain}/reg_01_naics.do"

*Aggregating the sectoral estimates (Aggregate)
local weightsused_FR=0
local typeused "agg" 
include "${cmain}/reg_02_agg.do"


log close


